<?php

namespace app\api\controller;

use app\common\controller\Api;

/**
 * 收货地址接口
 */
class Address extends Api
{

    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];

    
    protected $dataLimit = true;
    // protected $limitFields = 'name';
    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\common\model\Address();

    }

    /**
	 * 选择默认收货地址
    **/
    public function choose(){
    	if($this->request->isPost()){
    		$id = $this->request->post('id/d');
    		$this->model->where(['user_id' => $this->auth->id])->update(['is_default' => '0']);
    		$res = $this->model->where(['id' => $id])->update(['is_default' => '1']);

    		if($res !== false){
    			$this->success('选择默认地址成功');
    		}else{
    			$this->error('选择默认地址失败');
    		}
    	}
    }



    
}